package com.yima.baseproj.module.app.bill;

import com.yima.baseproj.aop.log.Logging;
import com.yima.baseproj.module.app.bill.model.AppBillSelectModel;
import com.yima.baseproj.module.app.pictureBill.PicBillService;
import com.yima.baseproj.module.config.utils.ResultVo;
import com.yima.baseproj.module.sys.bill.BillController;
import com.yima.baseproj.module.sys.bill.BillEntity;
import com.yima.baseproj.module.sys.bill.BillService;
import com.yima.baseproj.module.sys.picture.PictureEntity;
import com.yima.baseproj.security.SecurityUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "小程序订单管理")
@RestController
@RequestMapping("/api/app/bill")
public class AppBillController {

    @Autowired
    private BillService billService;

    @Autowired
    private PicBillService picBillService;

    @Logging(tags = "订单管理",value = "添加")
    @ApiOperation("添加")
    @PostMapping("/add")
    public void add(@RequestBody @Validated BillEntity bill) {

       billService.add(bill);
    }


    @ApiOperation("查询订单列表")
    @GetMapping("/findAllByParentId/{parentId}")
    public List<AppBillSelectModel> findAllByParentId(@PathVariable int parentId){
        return billService.findAllByParentId(parentId);
    }


    @ApiOperation("查询订单购买的图片")
    @GetMapping("/findPicByBillId/{id}")
    public List<PictureEntity> findPicByBillId(@PathVariable int id){
        return picBillService.findPicByBillId(id);
    }


    @ApiOperation("查询是否解锁全部底片")
    @GetMapping("/BillFindByType")
    public Long appBillFindByType(@RequestParam("studentId") int studentId, @RequestParam("parentId")int parentId){
        return billService.findBillByType(studentId,parentId);
    }



}
